package com.xyzwps.server.paimon.conf

import io.swagger.v3.oas.annotations.enums.ParameterIn
import io.swagger.v3.oas.models.parameters.Parameter
import org.springdoc.core.customizers.GlobalOpenApiCustomizer
import org.springdoc.core.customizers.OperationCustomizer
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class OpenApiConfiguration {

    @Bean
    fun scsOpenApiCustomizer(): GlobalOpenApiCustomizer {
        return GlobalOpenApiCustomizer { openApi ->
            val info = openApi.info
            info.title = "scs-cp openapi"
            info.description = "SCS Cloud Platform OpenAPI Documents"
            info.version = "0.0.1-snapshot"
        }
    }

    @Bean
    fun aopOperationCustomizer(): OperationCustomizer {
        return OperationCustomizer { operation, _ ->
            val parameter = Parameter()
                .name("locale")
                .`in`(ParameterIn.QUERY.toString())
                .example("zh-CN")
            operation.addParametersItem(parameter)
            operation
        }
    }
}
